package com.onemile.net;

import android.R.integer;
import android.util.Log;

import com.onemile.data.DXmlHead;
import com.onemile.data.DXml;
import com.onemile.data.DXml.FieldList;
import com.onemile.entity.Session;
import com.onemile.entity.UrlParams;
import com.onemile.entity.model.EAddress;
import com.onemile.entity.model.EOrder;
import com.onemile.entity.model.EUser;

public final class NetClient
{
   private static final int PAGE_SIZE = 20;

   /**
    * 发送
    * 
    * @param sendData
    * @return
    */
   private static DXml sendMessage(DXml sendData)
   {
	  try
	  {
		 String xml = HttpClient.sendMessage(UrlParams.PostURL, sendData.toBytes());
		 if (xml != null && !xml.equals(""))
		 {
			return new DXml(xml);
		 }
		 else
		 {
			return null;
		 }
	  }
	  catch (Exception e)
	  {
		 if (Session.getInstance().IsDEBUG())
		 {
			Log.e("ERROR", "NetClient_sendMessage(sendData) ", e);
		 }
	  }
	  return null;
   }

   /**
    * 
    * @param shopType
    * @param sortType
    *           1:ASC 2:DESC
    * @param sortField
    *           1:ShopsName,2:ShopsAddress,3:ShopsTel,4:ShopsPraise,5:ShopsPoor,
    *           6:ShopsType,7:RecommendedDishes,8:OpeningHours,9:Consumption,10:
    *           LowestPrice,11:Freight,12:Distance
    * @param pageNo
    * @param pageSize
    * @return
    */
   public static DXml GetShopListByType_S(String shopType, String sortType, String sortField, int pageNo, int pageSize, double latitude, double longitude)
   {
	  try
	  {
		 DXml data = new DXml();
		 data.AddHead(new DXmlHead(UrlParams.GetShopListByShopType_SL.APICode, pageNo, pageSize));
		 data.getBody().AddField(UrlParams.GetShopListByShopType_SL.ShopType, shopType);
		 data.getBody().AddField(UrlParams.GetShopListByShopType_SL.SortType, sortType);
		 data.getBody().AddField(UrlParams.GetShopListByShopType_SL.SortField, sortField);
		 data.getBody().AddField(UrlParams.GetShopListByShopType_SL.Latitude, String.valueOf(latitude));
		 data.getBody().AddField(UrlParams.GetShopListByShopType_SL.Longitude, String.valueOf(longitude));

		 return sendMessage(data);
	  }
	  catch (Exception e)
	  {
		 if (Session.getInstance().IsDEBUG())
		 {
			Log.e("ERROR", "NetClient_GetShopListByType(shopType,sortType, sortField, pageNo, pageSize) ", e);
		 }
	  }
	  return null;
   }

   /**
    * 
    * @param ShopsName
    * @param sortType
    * @param sortField
    * @param pageNo
    * @param pageSize
    * @return
    */
   public static DXml SearchShopListByName_S(String shopsName, String shopType, String sortType, String sortField, int pageNo, int pageSize, double latitude, double longitude)
   {
	  try
	  {
		 DXml data = new DXml();
		 data.AddHead(new DXmlHead(UrlParams.SearchShopListByShopName_SL.APICode, pageNo, pageSize));
		 data.getBody().AddField(UrlParams.SearchShopListByShopName_SL.ShopsName, shopsName);
		 data.getBody().AddField(UrlParams.SearchShopListByShopName_SL.ShopType, shopType);
		 data.getBody().AddField(UrlParams.SearchShopListByShopName_SL.SortType, sortType);
		 data.getBody().AddField(UrlParams.SearchShopListByShopName_SL.SortField, sortField);
		 data.getBody().AddField(UrlParams.SearchShopListByShopName_SL.Latitude, String.valueOf(latitude));
		 data.getBody().AddField(UrlParams.SearchShopListByShopName_SL.Longitude, String.valueOf(longitude));

		 return sendMessage(data);
	  }
	  catch (Exception e)
	  {
		 if (Session.getInstance().IsDEBUG())
		 {
			Log.e("ERROR", "NetClient_SearchShopListByName(shopsName, sortType, sortField, pageNo, pageSize) ", e);
		 }
	  }

	  return null;
   }

   /**
    * 
    * @param ShopsId
    * @return
    */
   public static DXml GetShopDetails(String ShopsId)
   {
	  try
	  {
		 DXml data = new DXml();
		 data.AddHead(new DXmlHead(UrlParams.GetShopDetailByShopId.APICode));
		 data.getBody().AddField(UrlParams.GetShopDetailByShopId.ShopsId, ShopsId);

		 return sendMessage(data);
	  }
	  catch (Exception e)
	  {
		 if (Session.getInstance().IsDEBUG())
		 {
			Log.e("ERROR", "NetClient_GetShopDetails(ShopsId) ", e);
		 }
	  }
	  return null;
   }

   /**
    * 
    * @param ShopsId
    * @param useGZip
    * @return
    */
   public static DXml GetShopBigImage(String ShopsId, boolean useGZip)
   {
	  try
	  {
		 DXml data = new DXml();
		 data.AddHead(new DXmlHead(UrlParams.GetShopBigImgByShopId.APICode, useGZip));
		 data.getBody().AddField(UrlParams.GetShopBigImgByShopId.ShopsId, ShopsId);

		 return sendMessage(data);
	  }
	  catch (Exception e)
	  {
		 if (Session.getInstance().IsDEBUG())
		 {
			Log.e("ERROR", "NetClient_GetShopBigImage(ShopsId, useGZip) ", e);
		 }
	  }
	  return null;
   }

   /**
    * 
    * @param shopId
    * @param sortType
    *           1:ASC,2:DESC
    * @param sortField
    *           1:CommodityName 2:Price 3:IsHot 4:IsNew 5:Rec_CreateTime
    * @param pageNo
    * @param pageSize
    * @return
    */
   public static DXml GetCommodityListByShopId_S(String shopId, String sortType, String sortField, int pageNo, int pageSize)
   {
	  try
	  {
		 DXml data = new DXml();
		 data.AddHead(new DXmlHead(UrlParams.GetCommodityListByShopId_S.APICode, pageNo, pageSize));
		 data.getBody().AddField(UrlParams.GetCommodityListByShopId_S.ShopsId, shopId);
		 data.getBody().AddField(UrlParams.GetCommodityListByShopId_S.SortType, sortType);
		 data.getBody().AddField(UrlParams.GetCommodityListByShopId_S.SortField, sortField);

		 return sendMessage(data);
	  }
	  catch (Exception e)
	  {
		 if (Session.getInstance().IsDEBUG())
		 {
			Log.e("ERROR", "NetClient_GetCommodityListByShopId(shopId, sortType, sortField, pageNo, pageSize) ", e);
		 }
	  }

	  return null;
   }

   /**
    * 
    * @param CommodityId
    * @param useGZip
    * @return
    */
   public static DXml GetCommoditySmallImage(String CommodityId, boolean useGZip)
   {
	  try
	  {
		 DXml data = new DXml();
		 data.AddHead(new DXmlHead(UrlParams.GetSmallCommodityImageByCommodityId.APICode, useGZip));
		 data.getBody().AddField(UrlParams.GetSmallCommodityImageByCommodityId.CommodityId, CommodityId);

		 return sendMessage(data);
	  }
	  catch (Exception e)
	  {
		 if (Session.getInstance().IsDEBUG())
		 {
			Log.e("ERROR", "NetClient_GetSmallCommodityImage(CommodityId, useGZip) ", e);
		 }
	  }
	  return null;
   }

   /**
    * 
    * @param CommodityId
    * @param useGZip
    * @return
    */
   public static DXml GetCommodityBigImage(String CommodityId, boolean useGZip)
   {
	  try
	  {
		 DXml data = new DXml();
		 data.AddHead(new DXmlHead(UrlParams.GetBigCommodityImageByCommodityId.APICode, useGZip));
		 data.getBody().AddField(UrlParams.GetBigCommodityImageByCommodityId.CommodityId, CommodityId);

		 return sendMessage(data);
	  }
	  catch (Exception e)
	  {
		 if (Session.getInstance().IsDEBUG())
		 {
			Log.e("ERROR", "NetClient_GetBigCommodityImage(CommodityId, useGZip) ", e);
		 }
	  }
	  return null;
   }

   /**
    * 
    * @param CommodityId
    * @return
    */
   public static DXml GetCommmodityDetails(String CommodityId)
   {
	  try
	  {
		 DXml data = new DXml();
		 data.AddHead(new DXmlHead(UrlParams.GetCommodityDetails.APICode));
		 data.getBody().AddField(UrlParams.GetCommodityDetails.CommodityId, CommodityId);

		 return sendMessage(data);
	  }
	  catch (Exception e)
	  {
		 if (Session.getInstance().IsDEBUG())
		 {
			Log.e("ERROR", "NetClient_GetCommmodityDetails(CommodityId) ", e);
		 }
	  }
	  return null;
   }

   /**
    * 
    * @param UserName
    * @param Password
    * @return
    */
   public static DXml Login(String UserName, String Password)
   {
	  try
	  {
		 DXml data = new DXml();
		 data.AddHead(new DXmlHead(UrlParams.Login.APICode));
		 data.getBody().AddField(UrlParams.Login.UserName, UserName);
		 data.getBody().AddField(UrlParams.Login.Password, Password);

		 return sendMessage(data);
	  }
	  catch (Exception e)
	  {
		 if (Session.getInstance().IsDEBUG())
		 {
			Log.e("ERROR", "NetClient_Login(UserName, Password) ", e);
		 }
	  }
	  return null;
   }

   /**
    * 
    * @param user
    *           只需要UserName，Password，Mobile，Email
    * @return
    */
   public static DXml Register(EUser user)
   {
	  try
	  {
		 DXml data = new DXml();
		 data.AddHead(new DXmlHead(UrlParams.Register.APICode));
		 data.getBody().AddField(UrlParams.Register.UserName, user.getUserName());
		 data.getBody().AddField(UrlParams.Register.Password, user.getPassword());
		 data.getBody().AddField(UrlParams.Register.Mobile, user.getMobile());
		 data.getBody().AddField(UrlParams.Register.Email, user.getEmail());

		 return sendMessage(data);
	  }
	  catch (Exception e)
	  {
		 if (Session.getInstance().IsDEBUG())
		 {
			Log.e("ERROR", "NetClient_Register(user) ", e);
		 }
	  }
	  return null;
   }

   /**
    * 
    * @param userId
    * @param shopId
    * @return
    */
   public static DXml InsertNewFavorite(String userId, String shopId)
   {
	  try
	  {
		 DXml data = new DXml();
		 data.AddHead(new DXmlHead(UrlParams.InsertNewFavorite.APICode));
		 data.getBody().AddField(UrlParams.InsertNewFavorite.UserId, userId);
		 data.getBody().AddField(UrlParams.InsertNewFavorite.ShopsId, shopId);

		 return sendMessage(data);
	  }
	  catch (Exception e)
	  {
		 if (Session.getInstance().IsDEBUG())
		 {
			Log.e("ERROR", "NetClient_NewFavorite(userId,shopId) ", e);
		 }
	  }
	  return null;
   }

   /**
    * 
    * @param userCollectionId
    * @return
    */
   public static DXml CancelFavorite(String userCollectionId)
   {
	  try
	  {
		 DXml data = new DXml();
		 data.AddHead(new DXmlHead(UrlParams.CancelFavorite.APICode));
		 data.getBody().AddField(UrlParams.CancelFavorite.UserCollectionId, userCollectionId);

		 return sendMessage(data);
	  }
	  catch (Exception e)
	  {
		 if (Session.getInstance().IsDEBUG())
		 {
			Log.e("ERROR", "NetClient_CancelFavorite(userCollectionId) ", e);
		 }
	  }
	  return null;
   }

   /**
    * 
    * @param UserId
    * @param pageNo
    * @param pageSize
    * @param SortField
    *           1:按名称 9：按价格
    * @param SortType
    *           1:ASC 2：DESC
    * @param ShopType
    *           空为不排序 1.餐馆 2.饮料 4.便利店
    * @return
    */
   public static DXml GetFavoriteShopListByUserId_S(String UserId, int pageNo, int pageSize, String SortField, String SortType, String ShopType)
   {
	  try
	  {
		 DXml data = new DXml();
		 data.AddHead(new DXmlHead(UrlParams.GetFavoritesListByUserId_S.APICode, pageNo, pageSize));
		 data.getBody().AddField(UrlParams.GetFavoritesListByUserId_S.UserId, UserId);
		 data.getBody().AddField(UrlParams.GetFavoritesListByUserId_S.SortField, SortField);
		 data.getBody().AddField(UrlParams.GetFavoritesListByUserId_S.SortType, SortType);
		 data.getBody().AddField(UrlParams.GetFavoritesListByUserId_S.ShopType, ShopType);

		 return sendMessage(data);
	  }
	  catch (Exception e)
	  {
		 if (Session.getInstance().IsDEBUG())
		 {
			Log.e("ERROR", "NetClient_GetFavoriteShopListByUserId(UserId,pageNo,pageSize) ", e);
		 }
	  }
	  return null;
   }

   /**
    * 
    * @param UserId
    * @param pageNo
    * @param pageSize
    * @param latitude
    * @param longitude
    * @return
    */
   public static DXml GetFavoriteShopListByUserId_SL(String UserId, int pageNo, int pageSize, double latitude, double longitude)
   {
	  try
	  {
		 DXml data = new DXml();
		 data.AddHead(new DXmlHead(UrlParams.GetFavoritesListByUserId_SL.APICode, pageNo, pageSize));
		 data.getBody().AddField(UrlParams.GetFavoritesListByUserId_SL.UserId, UserId);
		 data.getBody().AddField(UrlParams.GetFavoritesListByUserId_SL.Latitude, String.valueOf(latitude));
		 data.getBody().AddField(UrlParams.GetFavoritesListByUserId_SL.Longitude, String.valueOf(longitude));
		 return sendMessage(data);
	  }
	  catch (Exception e)
	  {
		 if (Session.getInstance().IsDEBUG())
		 {
			Log.e("ERROR", "GetFavoriteShopListByUserId_SL(UserId,pageNo,pageSize) ", e);
		 }
	  }
	  return null;
   }

   /**
    * 
    * @param CommodityId
    * @return
    */
   public static DXml GetCommodityInfo(String CommodityId)
   {
	  try
	  {
		 DXml data = new DXml();
		 data.AddHead(new DXmlHead(UrlParams.GetCommodityInfo.APICode));
		 data.getBody().AddField(UrlParams.GetCommodityInfo.CommodityId, CommodityId);

		 return sendMessage(data);
	  }
	  catch (Exception e)
	  {
		 if (Session.getInstance().IsDEBUG())
		 {
			Log.e("ERROR", "NetClient_GetCommodityInfo(GetCommodityInfo) ", e);
		 }
	  }
	  return null;
   }

   /**
    * 
    * @param shopsId
    * @return
    */
   public static DXml GetPromotions(String shopsId)
   {
	  try
	  {
		 DXml data = new DXml();
		 data.AddHead(new DXmlHead(UrlParams.GetPromotions.APICode));
		 data.getBody().AddField(UrlParams.GetPromotions.ShopsId, shopsId);
		 int size = Session.getInstance().getCommodityList().size();
		 if (size > 0)
		 {
			FieldList fl=data.getBody().AddFieldList(UrlParams.GetPromotions.CommodityIds);
			for (int i = 0; i < size; i++)
			{
              fl.AddField(UrlParams.GetPromotions.CommodityId, Session.getInstance().getCommodityList().get(i).getCommodityId());
			}
		 }

		 return sendMessage(data);
	  }
	  catch (Exception e)
	  {
		 if (Session.getInstance().IsDEBUG())
		 {
			Log.e("ERROR", "NetClient_GetPromotionsByShopsIs(shopsId) ", e);
		 }
	  }
	  return null;
   }

   /**
    * 
    * @param shopsId
    * @return
    */
   public static DXml GetCoupons(String shopsId,String userId)
   {
	  try
	  {
		 DXml data = new DXml();
		 data.AddHead(new DXmlHead(UrlParams.GetCoupons.APICode));
		 data.getBody().AddField(UrlParams.GetCoupons.ShopsId, shopsId);
		 data.getBody().AddField(UrlParams.GetCoupons.UserId, userId);
		 int size = Session.getInstance().getCommodityList().size();
		 if (size > 0)
		 {
			FieldList fl=data.getBody().AddFieldList(UrlParams.GetCoupons.CommodityIds);
			for (int i = 0; i < size; i++)
			{
              fl.AddField(UrlParams.GetCoupons.CommodityId, Session.getInstance().getCommodityList().get(i).getCommodityId());
			}
		 }

		 return sendMessage(data);
	  }
	  catch (Exception e)
	  {
		 if (Session.getInstance().IsDEBUG())
		 {
			Log.e("ERROR", "NetClient_GetCoupons(shopsId) ", e);
		 }
	  }
	  return null;
   }
   
   public static DXml GetCouponsByUserId_S(String userId, int PageNo, int PageSize)
   {
	  try
	  {
		 DXml data = new DXml();
		 data.AddHead(new DXmlHead(UrlParams.GetCouponByUserId_S.APICode, PageNo, PageSize));
		 data.getBody().AddField(UrlParams.GetCouponByUserId_S.UserId, userId);

		 return sendMessage(data);
	  }
	  catch (Exception e)
	  {
		 if (Session.getInstance().IsDEBUG())
		 {
			Log.e("ERROR", "NetClient_GetCouponsByUserId_S(userId, PageNo, PageSize, SortField, SortType) ", e);
		 }
	  }
	  return null;
   }


   /**
    * 
    * @param UserId
    * @param pageNo
    * @param pageSize
    * @param SortField
       
    * @param SortType
    *           1:ASC 2：DESC
    * @param ShopType
    *           空为不排序 1.餐馆 2.饮料 4.便利店
    * @return
    */
   public static DXml GetOrderListByUserId_S(String UserId, int pageNo, int pageSize, int OrderType,String ShopType)
   {
	  try
	  {
		 DXml data = new DXml();
		 data.AddHead(new DXmlHead(UrlParams.GetOrderListByUserId_S.APICode, pageNo, pageSize));
		 data.getBody().AddField(UrlParams.GetOrderListByUserId_S.UserId, UserId);
		 data.getBody().AddField(UrlParams.GetOrderListByUserId_S.ShopType, ShopType);
		 data.getBody().AddField(UrlParams.GetOrderListByUserId_S.OrderType, String.valueOf(OrderType));
		 
		 return sendMessage(data);
	  }
	  catch (Exception e)
	  {
		 if (Session.getInstance().IsDEBUG())
		 {
			Log.e("ERROR", "NetClient_GetFavoriteShopListByUserId(UserId,pageNo,pageSize) ", e);
		 }
	  }
	  return null;
   }
   
   /**
    * 
    * @param EOrder
    * @return
    */
   public static DXml InsertNewOrder(EOrder order)
   {
	  try
	  {
		 DXml data = new DXml();
		 data.AddHead(new DXmlHead(UrlParams.OrderSettle.APICode));
		 data.getBody().AddField("OrderAddress", order.getOrderAddress());
		 data.getBody().AddField("OrderMobile", order.getOrderMobile());
		 data.getBody().AddField("OrderName", order.getOrderName());
		 data.getBody().AddField("OrderRemarks", order.getOrderRemarks());
		 data.getBody().AddField("PromotionsId", order.getPromotionsId());
		 data.getBody().AddField("CouponId", order.getCouponId());
		 data.getBody().AddField("Rec_CreateBy", order.getRec_CreateBy());
		 data.getBody().AddField("Rec_ModifyBy", order.getRec_ModifyBy());
		 data.getBody().AddField("TotalPrice", String.valueOf(order.getTotalPrice()));
		 data.getBody().AddField("ShopId", order.getShopId());
		 data.getBody().AddField("UserId", order.getUserId());
		 data.getBody().AddField("EarliestTime", order.getEarliestTime());
		 data.getBody().AddField("LatestTime", order.getLatestTime());
		 data.getBody().AddField("Freight", String.valueOf(order.getFreight()));

		 // 添加orderDetails
		 FieldList fl = data.getBody().AddFieldList("OrderDetailsList");
		 int size1 = order.getOrderDetailsList().size();
		 for (int i = 0; i < size1; i++)
		 {
			FieldList flc = fl.AddFieldList("OrderDetails");
			flc.AddField("CommodityAccessoriesName", order.getOrderDetailsList().get(i).getCommodityAccessoriesName());
			flc.AddField("AttributeDetailsName", order.getOrderDetailsList().get(i).getAttributeDetailsName());
			flc.AddField("ActualTotalPrice", String.valueOf(order.getOrderDetailsList().get(i).getActualTotalPrice()));
			flc.AddField("Amount", String.valueOf(order.getOrderDetailsList().get(i).getAmount()));
			flc.AddField("CommodityId", order.getOrderDetailsList().get(i).getCommodityId());
			flc.AddField("CommodityName", order.getOrderDetailsList().get(i).getCommodityName());
			flc.AddField("CommodityPriceId", order.getOrderDetailsList().get(i).getCommodityPriceId());
			flc.AddField("Discount", String.valueOf(order.getOrderDetailsList().get(i).getDiscount()));
			flc.AddField("DiscountPrice", String.valueOf(order.getOrderDetailsList().get(i).getDiscountPrice()));
			flc.AddField("PromotionsId", order.getOrderDetailsList().get(i).getPromotionsId());
			flc.AddField("TotalPrice", String.valueOf(order.getOrderDetailsList().get(i).getTotalPrice()));
			flc.AddField("UnitPrice", String.valueOf(order.getOrderDetailsList().get(i).getUnitPrice()));

			// 添加Accessories
			FieldList fllODC = flc.AddFieldList("OrderDetailsAccessoriesList");
			int size2 = order.getOrderDetailsList().get(i).getOrderDetailsAccessoriesList().size();
			for (int j = 0; j < size2; j++)
			{
			   FieldList fllc = fllODC.AddFieldList("DetailsAccessories");
			   fllc.AddField("CommodityAccessoriesId", order.getOrderDetailsList().get(i).getOrderDetailsAccessoriesList().get(j).getCommodityAccessoriesId());
			}
			// 添加Attribut
			FieldList fllODA = flc.AddFieldList("OrderDetailsAttributeList");
			int size3 = order.getOrderDetailsList().get(i).getOrderDetailsAttributeList().size();
			for (int k = 0; k < size3; k++)
			{
			   FieldList flla = fllODA.AddFieldList("OrderDetailsAttribute");
			   flla.AddField("AttributeDetailsId", order.getOrderDetailsList().get(i).getOrderDetailsAttributeList().get(k).getAttributeDetailsId());
			}
		 }

		 return sendMessage(data);
	  }
	  catch (Exception e)
	  {
		 if (Session.getInstance().IsDEBUG())
		 {
			Log.e("ERROR", "NetClient_InsertNewOrder(order) ", e);
		 }
	  }
	  return null;
   }

   public static DXml InsertOrderAgain(String OrderId)
   {
	  try
	  {
		 DXml data = new DXml();
		 data.AddHead(new DXmlHead(UrlParams.AddNewOrderAgain.APICode));
		 data.getBody().AddField(UrlParams.AddNewOrderAgain.OrderId, OrderId);

		 return sendMessage(data);
	  }
	  catch (Exception e)
	  {
		 if (Session.getInstance().IsDEBUG())
		 {
			Log.e("ERROR", "NetClient_GetAddressListByUserId(UserId) ", e);
		 }
	  }
	  return null;
   }
   
   /**
    * 
    * @param UserId
    * @return
    */
   public static DXml GetAddressListByUserId(String UserId)
   {
	  try
	  {
		 DXml data = new DXml();
		 data.AddHead(new DXmlHead(UrlParams.GetAddressListByUserId.APICode));
		 data.getBody().AddField(UrlParams.GetAddressListByUserId.UserId, UserId);

		 return sendMessage(data);
	  }
	  catch (Exception e)
	  {
		 if (Session.getInstance().IsDEBUG())
		 {
			Log.e("ERROR", "NetClient_GetAddressListByUserId(UserId) ", e);
		 }
	  }
	  return null;
   }

   /**
    * 
    * @param eAddress
    * @return
    */
   public static DXml InsertNewAddress(EAddress eAddress)
   {
	  try
	  {
		 DXml data = new DXml();
		 data.AddHead(new DXmlHead(UrlParams.InsertNewAddress.APICode));
		 data.getBody().AddField(UrlParams.InsertNewAddress.AddressName, eAddress.getAddressName());
		 data.getBody().AddField(UrlParams.InsertNewAddress.UserId, eAddress.getUserId());
		 data.getBody().AddField(UrlParams.InsertNewAddress.Mobile, eAddress.getMobile());
		 data.getBody().AddField(UrlParams.InsertNewAddress.Consignee, eAddress.getConsignee());
		 data.getBody().AddField(UrlParams.InsertNewAddress.Address, eAddress.getAddress());
		 data.getBody().AddField(UrlParams.InsertNewAddress.Rec_CreateBy, eAddress.getRec_CreateBy());
		 data.getBody().AddField(UrlParams.InsertNewAddress.Rec_ModifyBy, eAddress.getRec_ModifyBy());

		 return sendMessage(data);
	  }
	  catch (Exception e)
	  {
		 if (Session.getInstance().IsDEBUG())
		 {
			Log.e("ERROR", "NetClient_InsertNewAddress ", e);
		 }
	  }
	  return null;
   }

   /**
    * 
    * @param eAddress
    * @return
    */
   public static DXml EditAddress(EAddress eAddress)
   {
	  try
	  {
		 DXml data = new DXml();
		 data.AddHead(new DXmlHead(UrlParams.UpdateAddress.APICode));
		 data.getBody().AddField(UrlParams.UpdateAddress.UserAddressId, eAddress.getUserAddressId());
		 data.getBody().AddField(UrlParams.UpdateAddress.UserId, eAddress.getUserId());
		 data.getBody().AddField(UrlParams.UpdateAddress.Mobile, eAddress.getMobile());
		 data.getBody().AddField(UrlParams.UpdateAddress.Consignee, eAddress.getConsignee());
		 data.getBody().AddField(UrlParams.UpdateAddress.Address, eAddress.getAddress());
		 data.getBody().AddField(UrlParams.UpdateAddress.AddressName, eAddress.getAddressName());
		 data.getBody().AddField(UrlParams.UpdateAddress.Rec_ModifyBy, eAddress.getRec_ModifyBy());

		 return sendMessage(data);
	  }
	  catch (Exception e)
	  {
		 if (Session.getInstance().IsDEBUG())
		 {
			Log.e("ERROR", "NetClient_EditAddress ", e);
		 }
	  }
	  return null;
   }

   /**
    * 
    * @param UserAddressId
    * @return
    */
   public static DXml DelAddress(String UserAddressId)
   {
	  try
	  {
		 DXml data = new DXml();
		 data.AddHead(new DXmlHead(UrlParams.GetAddressListByUserId.APICode));
		 data.getBody().AddField(UrlParams.DelAddress.UserAddressId, UserAddressId);

		 return sendMessage(data);
	  }
	  catch (Exception e)
	  {
		 if (Session.getInstance().IsDEBUG())
		 {
			Log.e("ERROR", "NetClient_DelAddress ", e);
		 }
	  }
	  return null;
   }


   
}
